package com.hzp.day51.dao;

import com.hzp.day51.model.Position;
import com.hzp.day51.util.RedisCache;

import java.util.List;

import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mybatis.spring.annotation.MapperScan;

@MapperScan
@CacheNamespace(implementation=com.hzp.day51.util.RedisCache.class)
public interface PositionMapper {
    @Delete({
        "delete from `position`",
        "where pos_id = #{posId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer posId);

    @Insert({
        "insert into `position` (pos_id, pos_name, ",
        "pos_age)",
        "values (#{posId,jdbcType=INTEGER}, #{posName,jdbcType=VARCHAR}, ",
        "#{posAge,jdbcType=INTEGER})"
    })
    int insert(Position record);

    int insertSelective(Position record);
    
    @Select({
        "select",
        "pos_id, pos_name, pos_age",
        "from `position`",
    })
    @ResultMap("com.hzp.day51.dao.PositionMapper.BaseResultMap")
    List<Position> selectAll();
    
    @Select({
        "select",
        "pos_id, pos_name, pos_age",
        "from `position`",
        "where pos_id = #{posId,jdbcType=INTEGER}"
    })
    @ResultMap("com.hzp.day51.dao.PositionMapper.BaseResultMap")
    Position selectByPrimaryKey(Integer posId);

    int updateByPrimaryKeySelective(Position record);

    @Update({
        "update `position`",
        "set pos_name = #{posName,jdbcType=VARCHAR},",
          "pos_age = #{posAge,jdbcType=INTEGER}",
        "where pos_id = #{posId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Position record);
}